package cn.anjubao.cp.api.controller;

import cn.anjubao.cp.api.dto.CountFeeReqForm;
import cn.anjubao.cp.api.dto.CountFeeResDto;
import cn.anjubao.cp.api.dto.unifiedPayReqForm;
import cn.anjubao.cp.api.pay.TradeOrderService;
import cn.anjubao.cp.common.base.BaseResponse;
import cn.anjubao.cp.common.base.exception.BusinessException;
import com.anjubao.parking.municipal.payment.dto.PayResponseDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pay")
public class TradeOrderController {
    private static final Logger logger = LoggerFactory.getLogger(TradeOrderController.class);
    @Autowired
    private TradeOrderService tradeOrderService;
    /**
     * 统一支付接口
     * @param reqForm
     * @return
     */
    @PostMapping("/unifiedPay")
    public BaseResponse<PayResponseDto> unifiedPay(@Validated @RequestBody unifiedPayReqForm reqForm)  throws BusinessException {
        logger.info("【统一支付】参数:{}",reqForm);
        return BaseResponse.success(tradeOrderService.unifiedPay(reqForm));
    }

    /**
     * 计算停费用和电子哨兵费用
     * @param reqForm
     * @return
     */
    @PostMapping("/countFee")
    public BaseResponse<CountFeeResDto> countFee(@Validated @RequestBody CountFeeReqForm reqForm) throws BusinessException {
        logger.info("【计算停车或者哨兵费用】参数:{}",reqForm);
        return BaseResponse.success(tradeOrderService.countFee(reqForm));
    }
}
